package com.he.service.Impl;

import com.he.mapper.BookstopMapper;
import com.he.pojo.Bookstop;
import com.he.pojo.BookstopExample;
import com.he.service.BookstopService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Collections;
import java.util.List;

/**
 * @author: He
 * @data 2025/10/17 14:04
 */
@Service
public class BookstopServiceImpl implements BookstopService {

    @Autowired
    private BookstopMapper bookstopMapper;

    @Override
    public List<Bookstop> selectAll() {

        BookstopExample bookstopExample = new BookstopExample();
        BookstopExample.Criteria criteria = bookstopExample.createCriteria();

        criteria.andBookidIsNotNull();

        List<Bookstop> bookstops = bookstopMapper.selectByExample(bookstopExample);

        return bookstops;
    }

    @Override
    public int insert(Bookstop bookstop) {

        int i = bookstopMapper.insert(bookstop);

        return i;
    }

    @Override
    public int update(Bookstop bookstop) {
        return bookstopMapper.updateByPrimaryKey(bookstop);
    }

    @Override
    public int delete(int id) {
        return bookstopMapper.deleteByPrimaryKey(id);
    }

    @Override
    public Bookstop selectById(int id) {

        Bookstop bookstop = bookstopMapper.selectByPrimaryKey(id);

        return bookstop;
    }
}
